﻿using System.Xml;

namespace RoughJs.Helper
{
    public class XmlHelper
    {
        public static XmlElement RenameElement(XmlNode e, string newName,string localName,string url)
        {
            XmlDocument doc = e.OwnerDocument;
            XmlElement newElement = doc.CreateElement(newName,localName,url);
            while (e.HasChildNodes)
            {
                newElement.AppendChild(e.FirstChild);
            }
            XmlAttributeCollection ac = e.Attributes;
            while (ac.Count > 0)
            {
                newElement.Attributes.Append(ac[0]);
            }
            XmlNode parent = e.ParentNode;
            parent.InsertBefore(newElement, e);
            parent.RemoveChild(e);
            return newElement;
        }

    }
}
